home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha 3.02 / source / Code ƒ / I-Menus.p < prev    next >
Encoding:
Text File  |  1990-09-15  |  3.6 KB  |  147 lines  |  [TEXT/PJMM]

  1. unit Menus;
  2.  
  3. interface
  4.  
  5.     uses
  6.         AboutWndo, Dialogs, Sound, GameUtils, Enemies, GlyphaGuts, MainWndo, Initialize;
  7.  
  8.     procedure DoPause;
  9.     procedure DoQuit;
  10.     procedure Handle_My_Menu (theMenu, theItem: integer; var theInput: TEHandle); {Handle menu selection}
  11.  
  12. {===================================}
  13.  
  14. implementation
  15.  
  16.     procedure DoPause;
  17.     begin
  18.         pausing := not pausing;
  19.     end;
  20.  
  21. {===================================}
  22.  
  23.     procedure DoQuit;
  24.     begin
  25.         doneFlag := TRUE;
  26.         SetEventMask(EveryEvent);
  27.         InitCursor;
  28.     end;
  29.  
  30. {===================================}
  31.  
  32.     procedure Handle_My_Menu;               {Handle menu selections realtime}
  33.         const
  34.             L_Apple = 201;                    {Menu list}
  35.             C_About_Glypha = 1;
  36.             L_Game = 202;                    {Menu list}
  37.             C_Begin = 1;
  38.             C_Pause = 2;
  39.             C_End = 3;
  40.             C_Quit = 5;
  41.             L_Options = 203;                {Menu list}
  42.             C_Configure_Game = 1;
  43.             C_Configure_Controls = 2;
  44.             C_Help = 4;
  45.             C_Clear_HiScores = 5;
  46.         var
  47.             DNA, index: integer;        {For opening DAs}
  48.             BoolHolder: boolean;        {For SystemEdit result}
  49.             DAName: Str255;            {For getting DA name}
  50.             SavePort: GrafPtr;            {Save current port when opening DAs}
  51.  
  52.     begin
  53.         case theMenu of                       {Do selected menu list}
  54.             L_Apple: 
  55.                 begin
  56.                     case theItem of                   {Handle all commands in this menu list}
  57.                         C_About_Glypha: 
  58.                             begin
  59.                                 D_AboutWndo(rightOffset, downOffset);            {Call a dialog for this menu selection}
  60.                             end;
  61.                         otherwise                {Handle the DAs}
  62.                             begin
  63.                                 GetPort(SavePort);
  64.                                 GetItem(AppleMenu, theItem, DAName); {Get the name of the DA selected}
  65.                                 DNA := OpenDeskAcc(DAName);   {Open the DA selected}
  66.                                 SetPort(SavePort);
  67.                             end;
  68.                     end;                        {End of item case}
  69.                 end;                        {End for this list}
  70.  
  71.             L_Game: 
  72.                 begin
  73.                     case theItem of            {Handle all commands in this menu list}
  74.                         C_Begin: 
  75.                             begin
  76.                                 if (pausing) then
  77.                                     begin
  78.                                         DoPause;
  79.                                     end
  80.                                 else
  81.                                     begin
  82.                                         if (not playing) then
  83.                                             begin
  84.                                                 playing := TRUE;
  85.                                                 SetEventMask(playMask);
  86.                                                 if (downOffset) < 20 then
  87.                                                     begin
  88.                                                         ClearMenuBar;
  89.                                                         DrawMenuBar;
  90.                                                         FlashMenuBar(0);
  91.                                                     end;
  92.                                                 levelOn := levelStart - 1;
  93.                                                 mortals := mortalsStart;
  94.                                                 score := 0;
  95.                                                 oldScore := 0;
  96.                                                 gameCycle := 0;
  97.                                                 nextMortal := 20000;
  98.                                                 SetCursor(ahnkCursor^^);
  99.                                                 if (keyboardControl) then
  100.                                                     HideCursor;
  101.                                                 AdvanceALevel;
  102.                                                 EnterANewMortal;
  103.                                                 lastLoopTime := TickCount;
  104.                                             end
  105.                                         else
  106.                                             begin
  107.                                             end;
  108.                                     end;
  109.                             end;
  110.                         C_Pause: 
  111.                             DoPause;
  112.                         C_End: 
  113.                             DoEnd;
  114.                         C_Quit: 
  115.                             DoQuit;
  116.                         otherwise
  117.                             begin
  118.                             end;
  119.                     end;                                {End of item case    }
  120.                 end;                                {End for this list        }
  121.  
  122.             L_Options: 
  123.                 begin
  124.                     case theItem of                {Handle all commands in this menu list    }
  125.                         C_Configure_Game: 
  126.                             D_ConfigureGameWndo(mortalsStart, levelStart, delayFor, soundOn, inhibitSound);        {Call a dialog for this menu selection}
  127.                         C_Configure_Controls: 
  128.                             D_ControlsWndo(keyboardControl);    {Call a dialog for this menu selection}
  129.                         C_Help: 
  130.                             DoHelpScreen;
  131.                         C_Clear_HiScores: 
  132.                             FlushTheScores;
  133.                         otherwise
  134.                             begin
  135.                             end;
  136.                     end;                        {End of item case        }
  137.                 end;                        {End for this list            }
  138.             otherwise
  139.                 begin
  140.                 end;
  141.         end;                            {End for lists                                }
  142.         HiliteMenu(0);                {Turn menu selection off                }
  143.     end;                                {End of procedure Handle_My_Menu    }
  144.  
  145. {===================================}
  146.  
  147. end.                                {End of unit                                }